/*
 * devices.h
 * 
 * Team: 11
 * Author: Tarl Hahn
 * Version: 1.0
 *
 * devices simulates both i/o devices and system timers
 * 
 */
 
 #ifndef DEVICES_H
 #define DEVICES_H
 
 #include "SharedMem.h"
 // #include InterruptManager <-- name may change...
 
 #define TIMER_STR "timer"
 #define NETWORK_STR "net"
 #define DISK_IO_STR "disk"
 #define VIDEO_STR "vid"
 #define MOUSE_STR "mouse"
 #define KEYBOARD_STR "key"
 
 typedef struct dev
 {
	int did;  // device id
	int pid;  // process currently working for
	int type; // type of device.  I.E. Timer, Disk i/o, network, Human interface i/o
	// priority level.  0 is the highest. priority determined by type.
	int time; // process completion time in microseconds 
	SharedMemPtr mem; // shared memory area
	pthread_t device_thread; // thread var
	pthread_mutex_t lock; // thread lock var
	
	int (*requestService)(struct dev*, int, SharedMemPtr); // request device <-- may not be needed if upon creation
											   // thread is created and waits for a condition var and a signal
											   // before running "service" then goes back into waiting.
	int (*destruct)(struct dev*); // destructs the struct.
	
 } Device;
 
 typedef Device* DevicePtr;
 
 // Constructor
 DevicePtr deviceConstruct(int did, int type);
 #endif 
 